package com.order.controller;

import com.common.domain.Pages.PageParams;
import com.common.domain.Pages.PageResult;
import com.common.domain.pojo.Result;
import com.order.domain.dto.OrderEvaluateDto;
import com.order.domain.dto.OrderReviewPageParams;
import com.order.domain.vo.OrderReviewPageVo;
import com.order.domain.vo.OrderReviewVo;
import com.order.service.IOrderReviewService;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/order/review")
public class OrderReviewController {

    @Resource
    IOrderReviewService iOrderReviewService;

    // 订单评价 - 订单信息
    @GetMapping
    public Result<OrderReviewVo> review(@RequestParam("orderId") Long orderId) {
        return Result.success(iOrderReviewService.review(orderId));
    }

    // 订单评价 - 提交评价
    @PostMapping("/evaluate")
    public Result<String> evaluate(@RequestBody OrderEvaluateDto orderEvaluateDto,
                                   HttpServletRequest httpServletRequest) {
        iOrderReviewService.evaluate(orderEvaluateDto,httpServletRequest);
        return Result.success();
    }

    // 分页获取课程评论数据
    @GetMapping("/list")
    public Result<OrderReviewPageVo> list(OrderReviewPageParams orderReviewPageParams) {
        OrderReviewPageVo pageResult = iOrderReviewService.pageList(orderReviewPageParams);
        return Result.success(pageResult);
    }
}
